import { stringify } from 'qs';
import request from '../utils/request';
import API from './ipConfig'

/**
 *会员列表
 *
 */
export async function findConsumerList() {
  return request(`${API}/sys/consumerManage/findConsumerList`, {
    method: 'GET',
  });
}

/**
 *通过分页获取会员列表
 *
 */
export async function findConsumerListPage(params) {
  return request(`${API}/sys/consumerManage/findConsumerList?index=${params.index}`, {
    method: 'GET',
  });
}

/**
 *查看会员详情
 *
 */
export async function getConsumerDetail(params) {
  return request(`${API}/sys/consumerManage/getConsumerDetail?consumerId=${params.consumerId}`, {
    method: 'GET',
  });
}

/**
 *会员编辑
 *
 */
export async function updateConsumer(params) {
  return request(`${API}/sys/consumerManage/updateConsumer`, {
    method: 'POST',
    body: params,
  });
}

/**
 *会员搜索
 *
 */
export async function SearchConsumer(params) {
  return request(`${API}/sys/consumerManage/findConsumerList?consumerName=${params.consumerName}`, {
    method: 'GET',
  });
}

/**
 *会员资金明细
 *
 */
export async function getConsumerFinancialDetails(params) {
  return request(`${API}/sys/consumerManage/getConsumerFinancialDetails?consumerId=${params.consumerId}`, {
    method: 'GET',
  });
}

/**
 *会员资金明细--搜索
 *
 */
export async function getConsumerFinancialDetailsSearch(params) {
  return request(`${API}/sys/consumerManage/getConsumerFinancialDetails?consumerId=${params.consumerId}&beginTime=${params.beginTime}&endTime=${params.endTime}&index=${params.index}`, {
    method: 'GET',
  });
}

/**
 *会员资金明细--换页
 *
 */
export async function getConsumerFinancialDetailsPage(params) {
  return request(`${API}/sys/consumerManage/getConsumerFinancialDetails?consumerId=${params.consumerId}&index=${params.index}`, {
    method: 'GET',
  });
}


/**
 * 会员转商家
 *
 * @export
 * @returns
 */
export async function vipChangeToBuyer(params) {
  return request(`${API}/sys/consumerManage/consumerShiftStore`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 删除会员
 *
 * @export
 * @returns
 */
export async function deleteVip(params) {
  return request(`${API}/sys/consumerManage/deleteConsumer`, {
    method: 'POST',
    body: params,
  });
}

/**
 * 充值接口
 *
 * @export
 * @returns
 */
export async function recharge(params) {
  return request(`${API}/app/index/recharge?` + stringify(params), {
    method: 'POST',
  });
}
